package com.nzx.common.result;

import com.nzx.common.enums.ResultStatusCodeEnum;
import lombok.Data;

/**
 * 类描述：结果返回工具类
 *
 * @author niezhuxe
 * @date 2021/11/5 0:15
 */
@Data
public class ResultCommon {

    public static ApiResult doSuccess(){

        ApiResult apiResult = new ApiResult();
        apiResult.setCode(ResultStatusCodeEnum.SUCCESS.getCode());
        apiResult.setMessage(ResultStatusCodeEnum.SUCCESS.value());
        return apiResult;
    }

    public static ApiResult doFail(){

        ApiResult apiResult = new ApiResult();
        apiResult.setCode(ResultStatusCodeEnum.FAIL.getCode());
        apiResult.setMessage(ResultStatusCodeEnum.FAIL.value());
        return apiResult;
    }

    public static ApiResult doFail(String message){

        ApiResult apiResult = new ApiResult();
        apiResult.setCode(ResultStatusCodeEnum.FAIL.getCode());
        apiResult.setMessage(message);
        return apiResult;
    }

    public static ApiResult doSuccess(Object data){

        ApiResult apiResult = new ApiResult();
        apiResult.setCode(ResultStatusCodeEnum.SUCCESS.getCode());
        apiResult.setMessage(ResultStatusCodeEnum.SUCCESS.value());
        apiResult.setData(data);
        return apiResult;
    }

    public static ApiResult doSuccess(String message,Object data){

        ApiResult apiResult = new ApiResult();
        apiResult.setCode(ResultStatusCodeEnum.SUCCESS.getCode());
        apiResult.setMessage(message);
        apiResult.setData(data);
        return apiResult;
    }
}
